<?php
/**
 * 
 * @author Administrator
 *
 */

class ModAttribute extends Model {

    protected $table = 'attribute';

    // 表名
    public function tableName(){
        return $this->table;
    }

    public static function model($className=__CLASS__){
        return parent::model($className);
    }

    public function getDbConnection(){
        return Yii::app()->dbOss;
    }

   
    
    public function select($params){
    	$table = $this->table;
    	$where  = ' WHERE game=:game ';
    	$args   = array(
    			':game'     => $params['g']
    	);
    	 
    	if(!empty($params['a_id'])){
    		$where .= " AND a_id like :a_id ";
    		$args['a_id'] = '%'.$params['a_id'].'%';
    	}
    
    	if(!empty($params['name'])){
    		$where .= " AND name like :name ";
    		$args['name'] = '%'.$params['name'].'%';
    	}    	 

    	$fields = "id,a_id,name";
    	$sql = "SELECT {$fields} FROM {$table} {$where}";
    	$data = $this->getDbConnection()->query($sql, $args);    	
    	return $data;
    }
    
    
    
} 